<?php
if (isset($InputData['list_type']) && isset($InputData['page_change'])) {
    $InputData['list_type'] = (int)$InputData['list_type'];
    //首页作品展示
    //连接作品数据模型
    require_once("{$CfgPara->root}/model/work.m.php");
    $myWork = new work_m($CfgPara->database);
    if ($isTablet) {
        $page_size = 8;
    } else {
        $page_size = 4;
    }
    if ($isTablet) {
        //PC版的需要直接获取总数量
        $workList = $myWork->work_list($InputData['list_type'], 0, $InputData['page_change'], $page_size, null, TRUE);
        $worksCount = $myWork->work_list_count;
    } else {
        $workList = $myWork->work_list($InputData['list_type'], 0, $InputData['page_change'], $page_size);
    }
    if (is_string($workList)) {
        echo($workList);
        goto page_end;
    }
    if ($InputData['list_type'] == 1 || $InputData['list_type'] == 2 || $InputData['list_type'] == 3 ||
        $InputData['list_type'] == 101 || $InputData['list_type'] == 102 ||
        $InputData['list_type'] == 103 || $InputData['list_type'] == 104
    ) {
        if ($isTablet) {
            //连接分页类 在列表最后加入分页栏
            if ($worksCount > 0) {
                require_once("{$CfgPara->root}/class/paginate.class.php");
                $myPaginate = new paginate_c();
                $myPaginate->change_func = "work_page_change({$InputData['list_type']},[x])";
                $paginateMsg = $myPaginate->paginate($InputData['page_change'], ceil($worksCount / $page_size));
            }
        }
        //$InputData['page_iscroll_load'] == 1 表示初始化加载
        if (isset($InputData['page_iscroll_load']) && $InputData['page_iscroll_load'] == 1) {
            if ($InputData['list_type'] > 100) {
                $seleBarItem = 1;
            } else {
                $seleBarItem = $InputData['list_type'];
            }
            $seleBarItem1 = "热门";
            $seleBarItem2 = "关注";
            $seleBarItem3 = "最新";
            $seleBarScript1 = "work_show_list(1,1)";
            $seleBarScript2 = "work_show_list(2,1)";
            $seleBarScript3 = "work_show_list(3,1)";
            require("{$viewRoot}list_sele_bar{$viewEx}");//加载整个页面视图
            if ($InputData['list_type'] == 1 || $InputData['list_type'] > 100) {
                if ($InputData['list_type'] > 100) {
                    $seleBarItem = $InputData['list_type'] - 100;
                } else {
                    $seleBarItem = 1; //如果当前仅指定热门 默认为24小时热门
                }
                $seleBarItem1 = "24小时热门";
                $seleBarItem2 = "昨日热门";
                $seleBarItem3 = "本周热门";
                $seleBarItem4 = "本月热门";
                $seleBarScript1 = "work_show_list(101,1)";
                $seleBarScript2 = "work_show_list(102,1)";
                $seleBarScript3 = "work_show_list(103,1)";
                $seleBarScript4 = "work_show_list(104,1)";
                require("{$viewRoot}list_sele_bar2{$viewEx}");//加载新的热门选项
            }
            require("{$viewRoot}works_show_list{$viewEx}");
        } else {
            if ($isTablet === true) {
                //平板、PC为换页
                require("{$CfgPara->root}/view/web/works_show_list_page.web.v.php");
            } else {
                //手机版仅加载下拉内容
                require("{$CfgPara->root}/view/works_show_list_content.app.v.php");
            }
        }
    }
}

page_end:;